package com.espeaker.sdk.model;

import com.espeaker.sdk.ParseException;
import org.json.JSONObject;

/**
 *
 * @author jimmy
 */
public class SubError implements IModel<SubError> {

    private static final String KEY_CODE = "code";
    private static final String KEY_MESSAGE = "message";

    private String code;
    private String message;

    @Override
    public SubError parse(Object object) {
        if (!(object instanceof JSONObject)) {
            throw new ParseException("SubError show parsed from JSONObject.");
        }

        JSONObject jsonObject = (JSONObject) object;
        code = jsonObject.optString(KEY_CODE);
        message = jsonObject.optString(KEY_MESSAGE);

        return this;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
